Ext.ns('cceaf.util');

Ext.define('cceaf.util.CmsHelper',{
	//extjs cmd只能通过类查找，需定义空类
});

cceaf.util.CmsHelper = (function() {
	
	return {
		
		/**
		 * 根据cms节点ID得到节点名称
		 * 
		 * @param nodeid 节点ID
		 * @return 节点名称
		 */
		getNodeNameByColumn: function(nodeid){
			var nodeName = "";

			if(nodeid != null){  
				Ext.Ajax.request({
					url: 'cmsDataProvider!getNodeNameByColumn.action',
					async: false,
					success: function(response){
						nodeName = response.responseText.ltrim();
						return nodeName;
					},
					params: {nodeid: nodeid}
				});
		  }

			return nodeName;
		},
		/**
		 * 站点ID获取站点中文名
		 * @param {Number} siteId 站点ID
		 * @return {String} 站点名
		 */
		getWebsiteName: function(siteId){
			var siteName;
			if(!Ext.isEmpty(siteId)){  
				Ext.Ajax.request({
					url: 'cmsmanager/website!findByKey.action',
					async: false,
					success: function(response){
						var responseText = response.responseText.ltrim();
						var json = Ext.decode(responseText);
						if (json.success) {
							siteName = json.data.siteName;
						} else {
							siteName = "";
						}
					},
					params: {siteId:siteId}
				});
		    }
		    return siteName;
		},
	
		/**
		 * 栏目ID获取栏目中文名
		 * @param {Number} colId 栏目ID
		 * @return {String} 栏目中文名
		 */
		getColumnName: function(colId){
			var colName;
			if(!Ext.isEmpty(colId)){  
				Ext.Ajax.request({
					url: 'cmsmanager/column!findByKey.action',
					async: false,
					success: function(response){
						var responseText = response.responseText.ltrim();
						var json = Ext.decode(responseText);
						if (json.success) {
							colName = json.data.colName;
						} else {
							colName= "";
						}
					},
					params: {colId:colId}
				});
		    }
		    return colName;
		},
		
			/**
		 * 栏目ID获取栏目内容属性
		 * @param {Number} colId 栏目ID
		 * @return {String}栏目内容属性
		 */
		getColumnContentType: function(colId){
			var contentType;
			if(!Ext.isEmpty(colId)){  
				Ext.Ajax.request({
					url: 'cmsmanager/column!findByKey.action',
					async: false,
					success: function(response){
						var responseText = response.responseText.ltrim();
						var json = Ext.decode(responseText);
						if (json.success) {
							contentType = json.data.contentType;
						} else {
							contentType= "";
						}
					},
					params: {colId:colId}
				});
		    }
		    return contentType;
		}
	};
	
}());
